﻿using System;
using DevExpress.Xpo;
using SmartPeople.Framework.SecuritySpace;

namespace SmartPeople.Framework.Security.Providers.XPO
{
    [Persistent("SecuritySession")]
    internal class XPSecuritySession : XPCustomObject, ISecuritySession
    {
        #region Fields

        [Key(AutoGenerate = true)]
        [Persistent("GID")]
        private Guid gID;

        [Persistent("UserGID")]
        private Guid userguid;

        [Persistent("IPAddress")]
        private string ipAddess;

        [Persistent("CreationTime")]
        private DateTime creationtime;

        [Persistent("TimeOut")]
        private Int32 timeout;

        [Persistent("LastActiveTime")]
        private DateTime lastactivetime;

        #endregion

        #region Properties

        [NonPersistent]
        public Guid GID
        {
            get { return gID; }
            set
            {
                if (gID != value)
                {
                    Guid OldValue = gID;
                    gID = value;
                    OnChanged("GID", OldValue, value);
                }
            }
        }

        [NonPersistent]
        public Guid UserGID
        {
            get { return userguid; }
            set
            {
                if (userguid != value)
                {
                    Guid OldValue = userguid;
                    userguid = value;
                    OnChanged("UserGID", OldValue, value);
                }
            }
        }


        [NonPersistent]
        public string IPAddress
        {
            get { return ipAddess; }
            set
            {
                if (ipAddess != value)
                {
                    string OldValue = ipAddess;
                    ipAddess = value;
                    OnChanged("IPAddress", OldValue, value);
                }
            }
        }


        [NonPersistent]
        public DateTime CreationTime
        {
            get { return creationtime; }
            set
            {
                if (creationtime != value)
                {
                    DateTime OldValue = creationtime;
                    creationtime = value;
                    OnChanged("CreationTime", OldValue, value);
                }
            }
        }


        [NonPersistent]
        public Int32 TimeOut
        {
            get { return timeout; }
            set
            {
                if (timeout != value)
                {
                    Int32 OldValue = timeout;
                    timeout = value;
                    OnChanged("TimeOut", OldValue, value);
                }
            }
        }


        [NonPersistent]
        public DateTime LastActiveTime
        {
            get { return lastactivetime; }
            set
            {
                if (lastactivetime != value)
                {
                    DateTime OldValue = lastactivetime;
                    lastactivetime = value;
                    OnChanged("LastActiveTime", OldValue, value);
                }
            }
        }

        #endregion
    }
}